var subBtn = document.querySelector("#tijiao");
var userName = document.querySelector("#user_name");
var telephone = document.querySelector("#telephone");
$("#tijiao").on("touchstart",function(){
		var re1 = /^[\u4e00-\u9fa5]{2,4}$/g;
		var re2 = /^1[34578]\d{9}$/;
		if(name1.value != name1.value.match(re1)) {
			name1.style.borderColor = "red";
			alert("请输入正确姓名");
		} else {
			name1.style.borderColor = "";
		}
		if(tel.value != tel.value.match(re2)) {
			tel.style.borderColor = "red";
			alert("请输入正确手机号码");
		}else {
			tel.style.borderColor = "";	
			$.ajax({
				type:"get",
				url:"http://zhangzhai.applinzi.com/k4/后台/k4_tijiao.php",
				async:true,
				data:{
					"name":userName.value,
					"telephone":telephone.value
				},
				success:function(data){
					var result = $.parseJSON(data);
                    if(result == "提交成功"){
                    		alert(result);
                        $("#shouqi").hide();
                        $("#bomBox").css("display","none");
                        $("#zhebu").hide();
                        $("#win").hide();
                    }else{
                        return;
                    }
                 }
			});
			$("#homeBackground").hide();
			$("#container").show();
		}
	});
$(".zhongjiangmingdan").on("touchstart",function(){
	$.ajax({
		type:"get",
		url:"http://zhangzhai.applinzi.com/k4/后台/k4_tiqu.php",
		async:true,
		success:function(data){
			var result = $.parseJSON(data);
			console.log(result);
			$("#con").html("");
			for(var i = 0;i < result.length;i++){
				var div = $("<div class='prize'></div>");
				var span_name = $("<span class='prize1'>" + result[result.length - 1 - i].name + "</span>");
				var span_telephone = $("<span class='prize1'>" + result[result.length - 1 - i].telephone + "</span>");
				var span_prize = $("<span class='prize1'>" + result[result.length - 1 - i].prize + "</span>");
				div.append(span_name);
				div.append(span_telephone);
				div.append(span_prize);
				$("#con").append(div);
			}
		}
	});
});
